<template>
  <el-config-provider :locale="locale" size="samll">
    <router-view />
  </el-config-provider>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import ElementZhCn from 'element-plus/lib/locale/lang/zh-cn'
import ElementEn from 'element-plus/lib/locale/lang/en'
import { generateNewStyle, writeNewStyle } from '@/utils/theme'
import { useAppStore } from '@/store'
import './assets/styles/index.scss'

const appStore = useAppStore()
const locale = computed(() => {
  const lang = appStore.language
  switch (lang) {
    case 'en':
      return ElementEn
    case 'zh':
      return ElementZhCn
    default:
      return ElementZhCn
  }
})

// 测试换肤功能
generateNewStyle(appStore.mainColor)
  .then((res) => writeNewStyle(res))
  .catch((err) => console.log(err))
</script>

<style lang="scss">
* {
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,
    Microsoft YaHei, Arial, sans-serif;
}
#app {
  height: 100%;
}
</style>
